要在 Nginx 的 sites-available 目录中为不同的域名配置网站,您可以按照以下步骤操作:
sites-available
目录下创建一个新的配置文件,例如 dreamforest.com.conf
。您可以使用以下命令创建新文件:vi /etc/nginx/sites-available/mydreamforest.com.conf
# server {
# listen 80;
# server_name dreamforest.com www.dreamforest.com;
# return 301 https://dreamforest.com:4443$request_uri;
# }
# 其一,LiveSync 填写的链接不能重定向;其二,80 端口留作 v2ray 的伪装网站
server {
listen 4443 ssl;
server_name dreamforest.com;
ssl_certificate /etc/letsencrypt/live/dreamforest.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dreamforest.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:5984;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_buffering off;
}
}
/var/www/dreamforest.com
替换为您网站的实际根目录。ln -s /etc/nginx/sites-available/mydreamforest.com.conf /etc/nginx/sites-enabled/
systemctl reload nginx
nginx -s reload
scp -r /path/to/local/dreamforest.com username@192.168.1.100:/var/www/dreamforest.com
sites-enabled
目录中的符号链接来禁用它rm /etc/nginx/sites-enabled/default
nginx -s reload
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name dreamforest.com;
root /var/www/dreamforest.com;
# 证书针对域名而不是路径,所以只能有 www.xxx.com !
ssl_certificate /etc/letsencrypt/live/dreamforest.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dreamforest.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/dreamforest.com/chain.pem;
index index.html index.htm; # 索引文件,首先尝试
location / {
try_files $uri $uri/ =404;
}
location ~* \.md$ {
if ($arg_raw = "true") {
break;
}
try_files /article.html =404;
}
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name www.dreamforest.com dreamforest.com;
return 301 https://dreamforest.com$request_uri;
}